/*
 * 生命周期绑定函数
 * 使用例子 <Comp v-visual-lifecycle="{mounted: ()=>{...}}" />
 */
const directive = {
  created(el, binding) {
    const op = binding.value;
    op?.created?.();
  },
  mounted(el, binding) {
    const op = binding.value;
    op?.mounted?.();
  },
  beforeUpdate(el, binding) {
    const op = binding.value;
    op?.beforeUpdate?.();
  },
  updated(el, binding) {
    const op = binding.value;
    op?.updated?.();
  },
  beforeUnmount(el, binding) {
    const op = binding.value;
    op?.beforeUnmount?.();
  },
  unmounted(el, binding) {
    const op = binding.value;
    op?.unmounted?.();
  },
};

if (!window.visualComp.directives['visual-lifecycle']) {
  window.visualComp.directives.push('visual-lifecycle');
  window.xVueWeb.app.directive('visual-lifecycle', directive);
}
